import random
from function import data_tool

import clickhouse_connect

connect_info = {
    'port': 8123,
    'host': '192.168.103.43',
    'username': 'admin',
    'password': '@Abcd1234',
    'database': 'nirvana_ahyd'
}
client = clickhouse_connect.get_client(**connect_info)
column_list = ['zy_master_org_id', 'zy_master_org_name_path', 'bwd_create_time', 'zy_master_account_name',
               'zy_master_parent_org_id', 'zy_master_account_id', 'zy_slave_account_name', 'kz_slave_account_type',
               'zy_slave_account_id', 'zy_op_time', 'kz_op_work_time_flag']
table_name = 'dws_slave_abnomal_time_login_local'
insert_data = []
num = 0
kz_slave_account_type_list = ['0', '1', '2', '3', '4', '5', '6', '99']
kz_op_work_time_flag_list = ['0', '1']
while num < 1000:
    zy_master_org_id = '227284'
    zy_master_org_name_path = '保旺达-研发体系-测试部'
    bwd_create_time = data_tool.DataTool().get_random_date('2025-05-01', '2025-05-20')
    zy_master_account_name = '威廉'
    zy_master_parent_org_id = '227283'
    zy_master_account_id = 'william'
    zy_slave_account_name = 'weilian'
    kz_slave_account_type = random.choice(kz_slave_account_type_list)
    zy_slave_account_id = 'bwd_weilian'
    zy_op_time = bwd_create_time.strftime('%Y-%m-%d %H:%M:%S')
    kz_op_work_time_flag = random.choice(kz_op_work_time_flag_list)
    insert_data.append(
        [zy_master_org_id, zy_master_org_name_path, bwd_create_time, zy_master_account_name, zy_master_parent_org_id,
         zy_master_account_id, zy_slave_account_name, kz_slave_account_type, zy_slave_account_id, zy_op_time,
         kz_op_work_time_flag])
    num += 1
client.insert(table_name, data=insert_data, column_names=column_list)
client.close()
